/**
 * Copyright &copy; 2012-2016 <a href="https://istep.lczyfz.com">Istep</a> All rights reserved.
 */
package com.lczyfz.istep.modules.resource.service;

import java.util.List;

import com.lczyfz.istep.common.constants.DeleteFlag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lczyfz.istep.common.persistence.Page;
import com.lczyfz.istep.common.service.CrudService;
import com.lczyfz.istep.modules.resource.entity.ResourceCoursesystem;
import com.lczyfz.istep.modules.resource.dao.ResourceCoursesystemDao;

/**
 * 课程体系Service
 * @author dh
 * @version 2017-01-16
 */
@Service
@Transactional(readOnly = true)
public class ResourceCoursesystemService extends CrudService<ResourceCoursesystemDao, ResourceCoursesystem> {
	@Autowired
	ResourceCoursesystemDao resourceCoursesystemDao
			;
	public ResourceCoursesystem get(String id) {
		return super.get(id);
	}
	
	public List<ResourceCoursesystem> findList(ResourceCoursesystem resourceCoursesystem) {
		return super.findList(resourceCoursesystem);
	}
	
	public Page<ResourceCoursesystem> findPage(Page<ResourceCoursesystem> page, ResourceCoursesystem resourceCoursesystem) {
		return super.findPage(page, resourceCoursesystem);
	}
	
	@Transactional(readOnly = false)
	public void save(ResourceCoursesystem resourceCoursesystem) {
		super.save(resourceCoursesystem);
	}

	@Transactional(readOnly = false)
	public void insert(ResourceCoursesystem resourceCoursesystem) {
		dao.insert(resourceCoursesystem);
	}
	@Transactional(readOnly = false)
	public void delete(ResourceCoursesystem resourceCoursesystem) {
		super.delete(resourceCoursesystem);
	}

	//添加下发-根据培训方案id获取课程体系
	public List<ResourceCoursesystem> findCourseSystemById(String trainProgramId){
		if( trainProgramId == null || trainProgramId.equals("") ){
			return resourceCoursesystemDao.findList(new ResourceCoursesystem());
		}else {
			return resourceCoursesystemDao.findCourseSystemById(trainProgramId, DeleteFlag.deleteFlag);
		}
	}

	/**
	 *根据课程体系id查询课程列表
	 * @param page
	 * @param resourceCoursesystem
	 * @return
	 */
	public Page<ResourceCoursesystem> findPageByTrainprogramId(Page<ResourceCoursesystem> page, ResourceCoursesystem resourceCoursesystem) {
		resourceCoursesystem.setPage(page);
		page.setList(dao.findPageByTrainprogramId(resourceCoursesystem));
		return page;
	}

	public ResourceCoursesystem findCoursesystemByName(ResourceCoursesystem resourceCoursesystem)
	{
		return dao.findCoursesystemByName(resourceCoursesystem);
	}


}